<?php 
include('../../Connections/KRAPPERCON.php');
?>

<?php
if (isset($_POST['cb_concepto'])){
if ($_POST['cb_concepto'] == ""){
$var =  "where marcacioncon = marcacioncon ";
}else{
$var = "where marcacioncon = '".$_POST['cb_concepto']."'";
}}

if (isset($_POST['t_fecini'])&& $_POST['t_fecini']!=""){
if (isset($_POST['t_fecfin'])&& $_POST['t_fecfin']==""){
$var = $var . " and DATE_FORMAT(MarcacionFecha, '%Y-%m-%d') = '".$_POST['t_fecini']."'";
}else{
$var = $var . " and DATE_FORMAT(MarcacionFecha, '%Y-%m-%d') >= '".$_POST['t_fecini']."'";
}
}

if (isset($_POST['t_fecfin'])&& $_POST['t_fecfin']!=""){
$var = $var ." and DATE_FORMAT(MarcacionFecha, '%Y-%m-%d') <= '".$_POST['t_fecfin']."'";
}
if (isset($_POST['t_usuario'])&& $_POST['t_usuario']!=""){
$var = $var ." and UserID = '".$_POST['t_usuario']."'";
}



?>


<table width="100%" id="tblrptmarc" border="0" rules="all">
<THEAD><TR> <TH>Fecha</TH> <TH>Hora</TH> <TH>Usuario</TH> <TH>Concepto</TH> <TH>Comentario</TH> </TR></THEAD>
<TBODY>
<?php


$query="
select DATE_FORMAT(MarcacionFecha, '%d/%m/%Y') as Fecha,Marcacionhora ,UserID,case when marcacioncon = '1' then 'Ingreso'
else 'Salida' end as Concepto,MarcacionDesc
from tt_marcacionusu mu 
".$var;

$res = $mysqli->query($query);
if ($res) {
		while($row = $res->fetch_assoc()) {
?>
 
 <TR> <TD><?php echo ($row["Fecha"])  ?></TD>
    <TD><?php echo ($row["Marcacionhora"]) ?></TD> 
    <TD><?php echo ($row["UserID"])  ?></TD>
     <TD><?php echo ($row["Concepto"])  ?></TD>
     <TD><?php echo ($row["MarcacionDesc"]) ?></TD>
	 </TR>

<?php
 	}
$res->close();
$mysqli->check_result();

  }


?>
</TBODY>
</table>